/**
 * Created by zxr on 16/6/1.
 */
var mysql = require('../mysql');
exports.getTeachers = function(mysql,callbackevent) {
    //mysql.connect();
    var sql = "select * from q_teacher";
    mysql.query(sql, function (err, rows, fileds) {
        var teachers = [];
        var uids = [];
        if (rows && rows.length > 0) {
            for (var i = 0; i < rows.length; i++) {
                var teacher = rows[i];
                teachers.push({
                    "tid": teacher.tid,
                    "tname": teacher.tname,
                    "pic": teacher.pic,
                    "video": teacher.video,
                    "intro": teacher.intro,
                    "uid": teacher.uid
                });
                uids.push(teacher.uid);
            }
            callbackevent.emit("teacherlist",{teachers:teachers,uids:uids})
        } else {
            callbackevent.emit("noteacher");
        }
        //mysql.close();
    });
};